package com.mjh.action;
import org.apache.log4j.Logger;
import com.opensymphony.xwork2.ActionSupport;
import com.mjh.bean.Article;
import com.mjh.comm.page.Pager;
import com.mjh.manager.ArticleSearchManager;

public class ArticleSearchAction extends ActionSupport{

	private static final long serialVersionUID = -5969814568349114819L;
	
	public static Logger log = Logger.getLogger(ArticleSearchAction.class);
	
	private ArticleSearchManager mgr = new ArticleSearchManager();
	
	private String keyWord;
	
	private int pageNo;
	
	private Pager<Article> pager;
	
	private int result;
	
	public String search(){
		if(pageNo == 0) pageNo = 1;
		pager = mgr.search(pageNo, keyWord);
		pager.setPageUrl("/search.do?pageNo=#pageNo#&keyWord="+keyWord);
		return SUCCESS;
	}
	
	public String rebuildIndex(){
		result = mgr.createIndex();
		return SUCCESS;
	}
	
	public int getResult() {
		return result;
	}

	public Pager<Article> getPager() {
		return pager;
	}

//	public String getKeyWord() {
//		return keyWord;
//	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

//	public int getPageNo() {
//		return pageNo;
//	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
}
